<template>
  <div class="workflow-form">
    <a-form
      :model="form"
      name="form"
      label-wrap
      :label-col="{ span: 24 }"
      :wrapper-col="{ span: 24 }"
      autocomplete="off"
    >
      <a-form-item
        label="条件判断类型"
        name="name"
        :rules="[{ required: true, message: '请选择条件判断类型', trigger: 'change' }]"
      >
        <a-select v-model:value="form.conditionType" placeholder="请选择条件判断类型">
          <a-select-option :value="0">由条件分支流条件决定</a-select-option>
          <a-select-option :value="1">由上一节点处理人决定</a-select-option>
        </a-select>
      </a-form-item>
    </a-form>
  </div>
</template>
<script lang="ts" setup name="WorkflowForm">
import { ref, toRefs, onBeforeUnmount, watch } from 'vue'
const emit = defineEmits(['close'])
const props = defineProps({
  currentNode: {
    type: Object,
    default: () => {}
  },
  isModal: {
    type: Boolean,
    default: false
  }
})

const form = ref<any>({})
const { currentNode } = toRefs(props)

let id = currentNode.value.data.id
form.value = currentNode.value.data.properties

watch(
  () => props.currentNode.data.properties,
  () => {
    console.log(11)
    id = currentNode.value.data.id
    form.value = currentNode.value.data.properties
  }
)

watch(
  () => props.currentNode.data.id,
  (val) => {
    emit('close', form.value, id)
    id = val
  }
)
onBeforeUnmount(() => {
  emit('close', form.value, id)
})
const close = () => {
  emit('close', form.value, id)
}
defineExpose({
  close
})
</script>
<style lang="less">
.workflow-form {
  width: 350px;
}
</style>
